//给定一个数组，数组长度为n，元素的范围也为n，将数组中的某个区间进行旋转，求旋转多少次以后，可以使数组中a[i]=i
//旋转指的是将区间最左边的元素放到最右边，整体再左移一位
//如果可以实现，返回区间的left,right和最小旋转次数；如果不能返回-1；如果不需要旋转就符合要求，返回0

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T > 0) {
            T--;
            int n = in.nextInt();
            int[] balls = new int[n + 1];
            //自己设置第一个元素为0
            for (int i = 1; i < n + 1; i++) {
                balls[i] = in.nextInt();
            }
            //找到中间nums[i]不等于i的区间，左右边界为left和right
            int left = 1;
            int right = n;
            while (left < right && balls[left] == left) {
                left++;
            }
            while (left < right && balls[right] == right) {
                right--;
            }
            if (left == right) {
                System.out.println(0);
            } else {
                int index = left;
                boolean res = true;
                for (int i = left; i <= right; i++) {
                    //找到这个区间的最大值，相当于旋转点
                    if (balls[i] == right) {
                        index = i;
                        break;
                    }
                }
                for (int i = left; i <= right; i++) {
                    //i为现在位置元素的索引，newI为现在的元素本来应该对应的索引
                    //比如i=4,nums[i]=1，则newI计算得到为1
                    //nums[i]应当与他原来应该在的位置newI相等
                    int newI = i - (index - left + 1) < left ? i - (index - left + 1) + (right - left + 1) : i - (index - left + 1);
                    if (newI != balls[i]) {
                        res = false;
                        break;
                    }
                }
                if (res) {
                    System.out.println(left + " " + right + " " + (index - left + 1));
                } else {
                    System.out.println(-1);
                }
            }
        }
    }
}
